package com.houkunlin.knife4j;

import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;
import springfox.documentation.schema.AlternateTypeRules;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author HouKunLin
 */
@ConditionalOnClass({Pageable.class, Sort.class, OpenApiExtensionResolver.class})
@Component
public class SpringDataDocketCustomizer implements DocketCustomizer {
    @Override
    public void customize(Docket docket) {
        docket
                .alternateTypeRules(AlternateTypeRules.newRule(Pageable.class, PageableModel.class, 1))
                .alternateTypeRules(AlternateTypeRules.newRule(Sort.class, PageableSortModel.class, 1));
    }


}
